package com.moyq5.mvc.maker.test.web;

import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * shiro配置
 * @author Moyq5
 * @date 2018年9月19日
 */
@Configuration
public class ShiroConfiguration {

	@Bean
	public ShiroFilterChainDefinition shiroFilterChainDefinition() {
	    DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
	    chainDefinition.addPathDefinition("/static/**", "anon");
	    chainDefinition.addPathDefinition("/login", "anon");
	    chainDefinition.addPathDefinition("/admin/login/**", "anon");
	    chainDefinition.addPathDefinition("/**", "authc"); // all paths are managed via annotations
	    
	    // or allow basic authentication, but NOT require it.
	    // chainDefinition.addPathDefinition("/**", "authcBasic[permissive]"); 
	    return chainDefinition;
	}
}
